1. Field of the Invention
The present invention relates to a filter circuit that smoothes an image while preserving an edge of the image, an image processing apparatus and an imaging apparatus including the filter circuit, an image processing method, and a computer program.
2. Description of the Related Art
In the past, in image processing apparatuses for still images, moving images, and the like, various filters (filter circuits) are used in order to improve image quality. As one of the filters, there is a filter called bilateral filter (see, for example, JP-A-2006-180268).
The bilateral filter is a nonlinear filter mainly used for noise removal and has a characteristic that the bilateral filter can realize smoothing of an image while preserving an edge of the image. In order to obtain this characteristic, the bilateral filter determines weight taking into account not only a distance between pixels but also a difference in pixel values (luminance) between the pixels. In the following explanation, a filter that can perform such processing is also referred to as an edge-preserving smoothing filter. A processing principle of the bilateral filter in the past is briefly explained with reference to FIGS. 10A to 10C.
FIGS. 10A to 10C are diagrams for explaining a principle of filter processing by a bilateral filter with a one-dimensional filter frame including five taps (five pixels) around a pixel of attention 71, i.e., a bilateral filter with a minimum filter frame of 1×5 pixels. FIG. 10A is a diagram of the distribution of weight coefficients in a space direction (weight coefficients concerning positions) in the pixel of attention 71 shown in FIG. 10B. FIG. 10B is a diagram of a relation between pixel positions and pixel levels in the pixel of attention 71 and peripheral pixels 72 around the pixel of attention 71. FIG. 10C is a diagram of the distribution of weight coefficients in a level direction (weight coefficients concerning a pixel level) in the pixel of attention 71.
In an example shown in FIGS. 10A to 10C, processing is performed with a pixel level Y2 of the pixel of attention 71 set as explained below. First, weights Wi (i=0 to 4) are calculated by the following Formula 1 in five pixels in positions X0 to X5 in a filter frame.Wi=Gspace(Xi−X2)×Glevel(Yi−Y2)  Formula 1
Gspace(x) and Glevel(y) in Formula 1 are distribution functions of weight coefficients in the space direction and the level direction in the respective pixels. In the bilateral filter, Gspace(x) and Glevel(y) are represented by Gaussian functions. Specifically, Gspace(x) and Glevel(y) are respectively represented by the following Formulas 2 and 3.Gspace(x)=exp[−x2/2σ2]  Formula 2Glevel(y)=exp[−y2/2σ2]  Formula 3
In the formulas, x in Formula 2 is equal to X1−X2 (i=0 to 4). y in Formula 3 is equal to Yi=Y2 (i=0 to 4). σ in Formula 2 represents a standard deviation parameter of the Gaussian function.
The pixel level Y2 of the pixel of attention 71 is subjected to correction (smoothing) processing by performing an arithmetic operation of the following Formula 4 using the weights Wi of the pixels and level values Yi of the pixels calculated by Formula 1. Y2′ in Formula 4 represents a pixel level of the pixel of attention 71 after the smoothing processing.
                              Y          ⁢                                          ⁢                      2            ′                          =                              ∑                          i              =              0                        4                    ⁢                                    (                              Wi                ×                Yi                            )                        /                                          ∑                                  i                  =                  0                                4                            ⁢              Wi                                                          Formula        ⁢                                  ⁢        4            
In the filter processing by the bilateral filter in the past, smoothness can be adjusted by changing the standard deviation parameter σ of the distribution functions Gspace(x) and Glevel (y) of the weight coefficients in the space direction and the level direction. Usually, the amplitude of a noise level is considered to be smaller than that of an edge in an image. Therefore, it is possible to smooth only noise while preserving the edge of the image by adjusting a of the distribution function Glevel (y) of the weight coefficient in the level direction to a standard deviation of the noise level.